package org.hqs.login.service;

import org.hqs.feign.clients.AdminClient;
import org.hqs.feign.clients.DoctorClient;
import org.hqs.feign.clients.NurseClient;
import org.hqs.feign.clients.PatientClient;
import org.hqs.feign.pojo.Admin;
import org.hqs.feign.pojo.Doctor;
import org.hqs.feign.pojo.Nurse;
import org.hqs.feign.pojo.Patient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    @Autowired
    private AdminClient adminClient;

    @Autowired
    private DoctorClient doctorClient;

    @Autowired
    private NurseClient nurseClient;

    @Autowired
    private PatientClient patientClient;

    public boolean isAdminRight(Integer id, String password) {
        Admin admin = adminClient.getAdminById(Long.valueOf(id)).getData();
        if (admin.getPassword().equals(password)) {
            return true;
        }
        return false;
    }

    public boolean isNurseRight(Long id, String password) {
        Nurse nurse = nurseClient.getNurseById(id).getData();
        if (nurse.getPassword().equals(password)) {
            return true;
        }
        return false;
    }

    public boolean isPatientRight(Long id, String password) {
        Patient patient = patientClient.queryById(id).getData();
        if (patient.getPassword().equals(password)) {
            return true;
        }
        return false;
    }

    public boolean isDoctorRight(Long id, String password) {
        Doctor doctor = doctorClient.queryDoctorById(id).getData();
        if (doctor.getPassword().equals(password)) {
            return false;
        }
        return true;
    }
}
